package online.exam.controller;

import online.exam.pojo.ClazzType;
import online.exam.service.ClazzTypeService;
import online.exam.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 王景煜
 */

@RequestMapping(value = "/clazz")
@RestController
public class ClazzTypeController {

    @Autowired
    private ClazzTypeService clazzTypeServiceImpl;

    @GetMapping("/queryAll/{page}/{limit}")
    public PageUtils<ClazzType> queryAll(@PathVariable Integer page, @PathVariable Integer limit) {
        return clazzTypeServiceImpl.queryAll(page, limit);
    }

    @GetMapping("/queryAll")
    public List<ClazzType> queryAll() {
        return clazzTypeServiceImpl.queryAll();
    }

    @GetMapping("/queryByName")
    public ClazzType queryByName(@RequestParam String name) {
        return clazzTypeServiceImpl.queryByName(name);
    }

    @PostMapping("/addClazzType")
    public int addClazzType(@RequestParam String name) {
        return clazzTypeServiceImpl.addClassType(name);
    }

    @PostMapping("/deleteClazzType")
    public int deleteClazzType(@RequestParam String id) {
        return clazzTypeServiceImpl.deleteClassType(id);
    }

}
